﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using GraphicsLib;

namespace TowerDefence.Tiles
{
    public interface IMountPoint : ITile
    {
        /// <summary>
        /// Add a tower to the mountpoint
        /// </summary>
        /// <param name="_tower">The tower to add</param>
        /// <returns>True if there was no existing tower present, false if there was</returns>
        bool AddTower(ITower _tower);

        /// <summary>
        /// Remove a tower from the mountpoint
        /// </summary>
        /// <returns>True if there was an existing tower, false if there wasn't</returns>
        bool RemoveTower();
    }

    public class MountPoint : Tile, IMountPoint
    {
        private ITower tower;

        public MountPoint(Vector2 _position) : base(_position) { }

        public bool AddTower(ITower _tower)
        {
            if (this.tower != null) return false;
            this.tower = _tower;
            return true;
        }

        public bool RemoveTower()
        {
            if (this.tower == null) return false;
            this.tower = null;
            return true;
        }

        public override void DebugDraw(Graphics2D _graphics)
        {
            _graphics.DrawRectangle(
                new Vector2(this.Position.X + 15, this.Position.Y + 15), 15, 15, Color.Orange);
        }
    }
}
